<?php
	function insertEvent(
		$p_event_title
			,$p_event_date
			,$p_event_time
			,$p_event_detail
			,$p_account_id
	
	){
		mysql_query("
			INSERT INTO TB_EVENT(
				EVENT_TITLE
					,EVENT_DATE
					,EVENT_TIME
					,EVENT_DETAIL
					,ACCOUNT_ID
	
			)VALUES(
				'".$p_event_title."'
					,'".$p_event_date."'
					,'".$p_event_time."'
					,'".$p_event_detail."'
					,'".$p_account_id."'
	
			)	
		")or die(mysql_error());
		return mysql_insert_id();
	}
	
	function updateEvent(
		$p_event_id
			,$p_event_title
			,$p_event_date
			,$p_event_time
			,$p_event_detail
	
	){
		mysql_query("
			UPDATE TB_EVENT 
			SET
				EVENT_TITLE='".$p_event_title."'
					,EVENT_DATE='".$p_event_date."'
					,EVENT_TIME='".$p_event_time."'
					,EVENT_DETAIL='".$p_event_detail."'
	
			WHERE EVENT_ID =  '".$p_event_id."'
		");
	}

	function getAllEvent($p_where_clause,$p_offset,$p_num_row,$p_order_by=" EVENT_ID DESC "){
		$rs = mysql_query("
		SELECT 
			EVENT_ID
				,EVENT_TITLE
				,EVENT_DATE
				,EVENT_TIME
				,EVENT_DETAIL
				,ACCOUNT_ID

		FROM TB_EVENT	
		WHERE 1 ".$p_where_clause."		
		ORDER BY ".$p_order_by."
		LIMIT ".$p_offset.",".$p_num_row."
		")or die(mysql_error());
		return $rs;
	}

	function getSingerEvent($p_event_id){
		$rs = mysql_query("
		SELECT 
			EVENT_ID
				,EVENT_TITLE
				,EVENT_DATE
				,EVENT_TIME
				,EVENT_DETAIL
				,ACCOUNT_ID

		FROM TB_EVENT	
		WHERE EVENT_ID =  '".$p_event_id."'		
		")or die(mysql_error());
		return $rs;
	}
	function getOwnerEvent( $p_event_id ){
		$rs = getSingerEvent( $p_event_id );
		if ( $arr = mysql_fetch_assoc($rs) ){
			return $arr['ACCOUNT_ID'];
		}
		return '';
	}
?>